//
//  ViewController.m
//  GongXiZhongJiang
//
//  Created by guo xiangyu on 4/5/18.
//  Copyright © 2018年 潇  岩. All rights reserved.
//

#import "ViewController.h"
#import "YaoHaoViewController.h"
#import "XiangqingViewController.h"

@interface ViewController (){
    
    UILabel *DiYiKuang;//首页红框
    UIButton *anniu;//首页按钮
    YaohaoModel *buhuo;//捕获
    
    
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    手势单指单击
    UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
    
//    文本框 首页红框
    DiYiKuang=[[UILabel alloc]initWithFrame:CGRectMake(50, 30, [UIScreen mainScreen].bounds.size.width-100, [UIScreen mainScreen].bounds.size.height/2)];
    DiYiKuang.text=@"来摇一下吧";
    DiYiKuang.backgroundColor=[UIColor redColor];
    [DiYiKuang setTintColor:[UIColor grayColor]];
    DiYiKuang.textAlignment = UITextAlignmentCenter;//不了解
    DiYiKuang.font= [UIFont systemFontOfSize:20];
    DiYiKuang.textColor = [UIColor whiteColor];
    [DiYiKuang addGestureRecognizer:labelTapGestureRecognizer];
    DiYiKuang.userInteractionEnabled = YES; // 可以理解为设置label可被点击
    [self.view addSubview:DiYiKuang];
    
    
//    按钮 首页按钮
    anniu=[[UIButton alloc]init];
    anniu.frame=CGRectMake(100,  [UIScreen mainScreen].bounds.size.height/2+80, [UIScreen mainScreen].bounds.size.width-200, 50);
    [anniu setBackgroundColor:[UIColor blueColor]];
    [anniu setTitle:@"开始摇奖" forState:UIControlStateNormal];
    [anniu setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];//不够了解
    anniu.titleLabel.font=[UIFont systemFontOfSize:30];//不够了解
    [anniu addTarget:self action:@selector(DiYiTiao) forControlEvents:UIControlEventTouchUpInside];
    anniu.layer.cornerRadius=20;//不够了解
    anniu.layer.masksToBounds=YES;//不够了解
    [self.view addSubview:anniu];
    // Do any additional setup after loading the view, typically from a nib.
}


//首页按钮的反应跳转页面
-(void)DiYiTiao{
    
    NSLog(@"开始摇奖");
    YaoHaoViewController *yaohao=[[YaoHaoViewController alloc]init];
    yaohao.delegete=self;
     [self  presentViewController:yaohao  animated:YES completion:nil];
    
}



// 首页红框按下去的反应
- (void)labelClick {
    XiangqingViewController *xiangq=[[XiangqingViewController alloc]init];
    xiangq.jieshou2=buhuo;
    [self presentViewController:xiangq  animated:YES completion:nil];
}



//代理方法，使红框文字改变
-(void)YaoHaoViewControllerDelegete:(YaohaoModel *)ssString{
    buhuo=ssString;
     DiYiKuang.text=buhuo.choujianghao;
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
